package apis

import (
	"github.com/gin-gonic/gin"
	"mini-gde/client"
	"mini-gde/pkg"
	"net/http"
)

func CloneRepo(c *gin.Context) {
	req := make(map[string]string)
	c.BindJSON(&req)
	git := client.GitClient{}
	apps, err := git.CloneRepo(req["url"])
	if err != nil {
		c.JSON(http.StatusInternalServerError, gin.H{
			"code": pkg.ERROR,
			"msg":  pkg.GetMsg(pkg.ERROR),
		})

	} else {
		c.JSON(http.StatusOK, gin.H{
			"code": pkg.SUCCESS,
			"msg":  pkg.GetMsg(pkg.SUCCESS),
			"apps": apps,
		})
	}

}
